<template>
	<view class="address-form" :data-theme='theme()' :class="theme() || ''">
		<form @submit="formSubmit" @reset="formReset">
			<view class="bg-white p-0-40 f30">
				<view class="d-s-c border-b-d9">
					<text class="key-name" style="width: 100px;">店主电话</text>
					<input class="ml20 flex-1 p-30-0 lh150" type='tel' name="phone" v-model="phone"
						placeholder-class="grary9" placeholder="请输入店主电话"></input>
				</view>
			</view>
			<view class="p30"><button form-type="submit" class="theme-btn f32 mt60 addBtn">保存</button></view>
		</form>

	</view>
</template>

<script>
	export default {

		data() {
			return {
				phone: '',
				delta: 1,
				is_load: false
			};
		},
		onLoad: function(options) {
			this.getSetingData()
		},
		methods: {
			/*获取数据*/
			getSetingData() {
				let self = this;
				uni.showLoading({
					title: '加载中'
				});
				self._get('user.index/setting', {}, function(res) {
					self.userInfo = res.data.userInfo;
					self.phone = self.userInfo.agent.store_mobile
					uni.hideLoading();
				});
				// #ifdef APP-PLUS
				plus.runtime.getProperty(plus.runtime.appid, function(widgetInfo) {
					self.version_no = widgetInfo.version;
				});
				// #endif
			},
			/*提交*/
			formSubmit: function(e) {

				if (this.phone == '') {
					uni.showToast({
						title: '请输入提货电话',
						duration: 1000,
						icon: 'none'
					});
					return false;
				}
				let self = this;
				self._post('user.agent/setStoreMobile', {
					phone: this.phone
				}, function(res) {
					self.showSuccess(res.msg, function() {
						// #ifndef H5
						uni.navigateBack({
							delta: parseInt(self.delta)
						});
						// #endif
						// #ifdef H5
						history.go(-self.delta);
						// #endif
					});
				});
			},

			formReset: function(e) {
				console.log('清空数据');
			},

		}
	};
</script>

<style>
	page {
		background-color: #FFFFFF;
	}

	.address-form {
		/* border-top: 16rpx solid #f2f2f2; */
	}

	.address-form .key-name {
		width: 140rpx;
		font-size: 32rpx
	}

	.address-form .btn-red {
		height: 88rpx;
		line-height: 88rpx;
		border-radius: 44rpx;
		box-shadow: 0 8rpx 16rpx 0 rgba(226, 35, 26, .6);
	}

	.addBtn {
		height: 80rpx;
		line-height: 80rpx;
		border-radius: 40rpx;
	}
</style>